package com.csdj.music.controller;

import com.csdj.music.service.AdminService;
import com.csdj.music.vo.RespBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName: AdminController
 * @Author: ZouLi
 * @Description: 管理员控制器
 * @Date: 2023/3/13 15:38
 **/
@RestController
@Api(tags = "管理员控制器")
@RequestMapping("/admin")
public class AdminController {

    /**
     AdminService
     **/
    @Autowired
    private AdminService adminService;

    @ApiOperation(value = "后台登录")
    @PostMapping("/login")
    public RespBean login(String username, String password, String code, HttpServletRequest request){
        System.out.println(code);
        return adminService.login(username, password, code, request);
    }

    /**
     * @Description: 退出登录
     * @Param []
     * @Return com.csdj.music.vo.RespBean
     * @Throws
     **/
    @PostMapping("/logout")
    @ApiOperation(value = "退出登录")
    public RespBean logout(){
        return RespBean.success("注销成功！已为您跳转至登录页面~");
    }
}
